package com.compass.ui.client;

import com.extjs.gxt.ui.client.widget.ContentPanel;
import com.extjs.gxt.ui.client.widget.layout.AccordionLayout;
import com.google.gwt.user.client.Element;
import com.google.gwt.user.client.Random;

public class CommentPanel extends ContentPanel
{
	ContentPanel s01;
	ContentPanel s02;
	ContentPanel s03;
	ContentPanel s04;
	int prev;
	
	public CommentPanel()
	{
		prev = -1;
		AccordionLayout stackLayout = new AccordionLayout();
		stackLayout.setHideCollapseTool(true);
		setLayout(stackLayout);
		setHeading("Commentaires sur la courbe");
		s01 = new ContentPanel();
		s01.setHeading("S01 - Du 01/01/12 au 07/01/12");
		s02 = new ContentPanel();
		s02.setHeading("S02 - Du 08/01/12 au 14/01/12");
		s03 = new ContentPanel();
		s03.setHeading("S03 - Du 15/01/12 au 21/01/12");
		s04 = new ContentPanel();
		s04.setHeading("S04 - Du 22/01/12 au 28/01/12");
		setBodyBorder(false);
		setBorders(false);
		s01.addText("Ceci est un commentaire");
		s01.addText("Un autre commentaire...");
		s02.addText("Commentaire de la semaine 02");
		s03.addText("Semaine 03....");
		s04.addText("Semaine 04....");
		add(s01);
		add(s02);
		add(s03);
		add(s04);
		this.setWidth("200px");
		this.setHeight("418px");
	}
	
	@Override
	protected void onRender(Element parent, int pos)
	{
		super.onRender(parent, pos);
	}
	
	public void	randomExpand()
	{
		int i = Random.nextInt(4);
		while (prev == i)
		{
			i = Random.nextInt(4);
		}
		prev = i;
		switch (i)
		{
		case 0:
			s01.expand();
			break;
		case 1:
			s02.expand();
			break;
		case 2:
			s03.expand();
			break;
		case 3:
			s04.expand();
			break;
		default:
			s02.expand();
			break;
		}
	}
}
